{% extends "base.html" %}
{% load i18n bootstrap3 dv_filters %}
{% block head_title %}{{ season.desc }}{% endblock %}

{% block container-class %}container-fluid{% endblock %}

{% block content %}
    {% include "challenge/season_header.html" with season=season only %}
    <h4>{% trans "Disponibilités" %}</h4>

    <form method="POST" action="" class="form-horizontal">
        {% csrf_token %}
        <div class="table-avail-wrapper">
          <table class="table text-center table-avail">
            {% include "challenge/season_availability_thead.html" with sessions=sessions season=season user=request.user preamble_columns=1 wishfield=True user_can_see_season=user_can_see_season only %}
            <tbody>
                {% for helper_category,helpers in potential_helpers %}
                    {% if helpers %}
                        {% for helper in helpers %}
                        <tr>
                            <td class="text-left">{{ helper.get_full_name }}</td>
                            {{ form|useravailsessions:helper }}
                        </tr>
                        {% endfor %}
                        {% if helpers.count > 10 %}
                            {% include "challenge/season_availability_partial_head.html" with sessions=sessions season=season user=request.user preamble_columns=2 only %}
                        {% endif %}
                    {% endif %}
                {% endfor %}
            </tbody>
          </table>
        </div>
        {% buttons %}
            <button type="submit" class="btn btn-primary pull-right">{% trans "Enregistrer" %}</button>
            {% if request.user|can:'challenge_season_crud' and user|anyofusercantons:season.cantons %}
                <a class="btn btn-default" href="{% url 'season-availabilities' pk=season.pk %}">{% trans "Annuler" %}</a>
            {% else %}
                <a class="btn btn-default" href="{% dv_season_url season.begin %}">{% trans "Annuler" %}</a>
            {% endif %}
        {% endbuttons %}
     </form>

{% endblock %}
